﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Concat
{
    [System.Diagnostics.DebuggerNonUserCode]
    class Location
    {
        public bool hasValues;
        public string file;
        public int pos, line, col;

        public Location(string file, int pos, int line, int col)
        {
            hasValues = true;
            this.file = file;
            this.pos = pos;
            this.line = line;
            this.col = col;
        }
        private Location()
        {
            hasValues = false;
        }

        public static Location External
        {
            get
            {
                return new Location();
            }
        }

        public static int operator -(Location end, Location start)
        {
            return end.pos - start.pos;
        }

        public override string ToString()
        {
            if (hasValues)
                return file + ", line " + (line + 1) + ", col " + (col + 1);
            else
                return "(external source)";
        }
    }
}
